package cn.circle.system.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import cn.circle.commom.model.DataGrid;
import cn.circle.system.dao.ISysDepartmentDao;
import cn.circle.system.model.SysDepartment;
import cn.circle.system.service.ISysDepartmentService;
import cn.circle.system.util.FileUploadUtil;

@Repository
public class SysDepartmentService implements ISysDepartmentService{

	@Autowired
	private ISysDepartmentDao sysDepartmentDao;
	DataGrid dg = new DataGrid();
	
	@Override
	public DataGrid datagrid() {
		// TODO Auto-generated method stub
		
		List<SysDepartment> l = sysDepartmentDao.datagrid();
		dg.setRows(l);
		dg.setTotal((long)l.size());
		return dg;
	}

	@Override
	public boolean save(SysDepartment sysDepartment) {
		// TODO Auto-generated method stub
		sysDepartmentDao.save(sysDepartment);
		return true;
	}

	@Override
	public List<SysDepartment> getUser(String id) {
		// TODO Auto-generated method stub
		return sysDepartmentDao.getUser(id);
	}

	@Override
	public boolean remove(String depIds) {
		// TODO Auto-generated method stub
		sysDepartmentDao.removeAll(depIds);
		return false;
	}

	@Override
	public boolean delete(String depIds) {
		// TODO Auto-generated method stub
//		if (sysDepartmentDao.deleteAll(depIds)){
//			sysDepartmentDao.deleteAllFile(depIds);
//		}
//		List<String> s = sysDepartmentDao.getFilePath(depIds);
//		if (sysDepartmentDao.deleteAll(depIds)){
//			FileUploadUtil.deleteFile(s);
//		}
		sysDepartmentDao.deleteAll(depIds);
		return false;
	}

	@Override
	public boolean update(SysDepartment sysDepartment) {
		// TODO Auto-generated method stub
		sysDepartmentDao.updateIt(sysDepartment);
		return false;
	}

	@Override
	public List<SysDepartment> getAllDepaetment(Integer type, Integer depId) {
		// TODO Auto-generated method stub
		return sysDepartmentDao.getAllDepaetment(type,depId);
	}

}
